package com.cn.wanxi.IO;

import com.cn.wanxi.IOModel.ProductModelIO;
import com.cn.wanxi.util.Tool;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;

public class ProductIO {
    public void writeNote(String path) {
        File file = new File(path);
        try {
            file.createNewFile();
            OutputStream outputStream = new FileOutputStream(file);
            ProductModelIO productModelIO = new ProductModelIO();
            outputStream.write(Arrays.toString(productModelIO.getImgsForHome()).getBytes());
            outputStream.write(Tool.split.getPath().getBytes());
            outputStream.write(Arrays.toString(productModelIO.getTitlesForHome()).getBytes());
            outputStream.write(Tool.split.getPath().getBytes());
            outputStream.write(Arrays.toString(productModelIO.getContentForHome()).getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void writeNoteForProduct(String path) {
        File file = new File(path);
        try {
            file.createNewFile();
            OutputStream outputStream = new FileOutputStream(file);
            ProductModelIO productModelIO = new ProductModelIO();
            outputStream.write(Arrays.toString(productModelIO.getImgsForProductPage()).getBytes());
            outputStream.write(Tool.split.getPath().getBytes());
            outputStream.write(Arrays.toString(productModelIO.getTitlesForProductPage()).getBytes());
            outputStream.write(Tool.split.getPath().getBytes());
            outputStream.write(Arrays.toString(productModelIO.getPricesForProductPage()).getBytes());
            outputStream.write(Tool.split.getPath().getBytes());
            outputStream.write(Arrays.toString(productModelIO.getContentsForProductPage()).getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
